CREATE TABLE [dbo].[FACTURAS_DETALLES]
(
[ID] [numeric] (10, 0) NOT NULL,
[ID_PRODUCTO] [numeric] (10, 0) NOT NULL,
[PRECIO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_PRECIO] DEFAULT ((0)),
[COSTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_COSTO] DEFAULT ((0)),
[CANTIDAD] [numeric] (10, 2) NOT NULL,
[DESCUENTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_DESCUENTO] DEFAULT ((0)),
[X_DESCUENTO] [numeric] (10, 4) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_X_DESCUENTO] DEFAULT ((0)),
[IMPUESTO] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_IMPUESTO] DEFAULT ((0)),
[X_IMPUESTO] [numeric] (10, 4) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_X_IMPUESTO] DEFAULT ((0)),
[C_DEVUELTA] [numeric] (10, 2) NOT NULL CONSTRAINT [DF_FACTURAS_DETALLES_C_DEVUELTA] DEFAULT ((0))
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[FACTURAS_DETALLES] ADD CONSTRAINT [PK_FACTURAS_DETALLES] PRIMARY KEY CLUSTERED  ([ID], [ID_PRODUCTO]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[FACTURAS_DETALLES] ADD CONSTRAINT [FK_FACTURAS_DETALLES_FACTURAS] FOREIGN KEY ([ID]) REFERENCES [dbo].[FACTURAS] ([ID]) ON DELETE CASCADE
GO
ALTER TABLE [dbo].[FACTURAS_DETALLES] ADD CONSTRAINT [FK_FACTURAS_DETALLES_PRODUCTOS] FOREIGN KEY ([ID_PRODUCTO]) REFERENCES [dbo].[PRODUCTOS] ([ID])
GO
